﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class news_ModuleCell : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            bd();
        }
    }
    void bd()
    {

    }

    public string ModuleId
    {
        get
        {
            if (ViewState["ModuleId"] == null)
            {
                return string.Empty;
            }
            else
            {
                return ViewState["ModuleId"].ToString();
            }
        }
        set
        {
            ViewState["ModuleId"] = value;
        }
    }

    public int Hangshu
    {
        get
        {
            if (ViewState["Hangshu"] == null)
            {
                return 0;
            }
            else
            {
                return int.Parse(ViewState["Hangshu"].ToString());
            }
        }
        set
        {
            ViewState["Hangshu"] = value;
        }
    }

    void init()
    {
        for (int i = 1; i <= 9; i++)
        {
            ((TextBox)this.FindControl("txtTitle" + i.ToString())).Text = "";
            ((HiddenField)this.FindControl("hidColor" + i.ToString())).Value = "";
            ((HiddenField)this.FindControl("hidBold" + i.ToString())).Value = "";
            ((TextBox)this.FindControl("txtValue" + i.ToString())).Text = "";
        }
    }


    public void LoadData(List<NUrl> lst)
    {
        init();
        if (lst == null)
        {
            return;
        }
        for (int i = 0; i < lst.Count; i++)
        {
            var d = lst[i];
            string kName = "txtTitle" + (i + 1).ToString();
            var txtBox = (TextBox)this.FindControl(kName);
            txtBox.Text = d.Text;
            txtBox.Style.Add("color", d.Color);
            txtBox.Style.Add("font-weight", d.FontWeight);
            ((TextBox)this.FindControl("txtValue" + (i + 1).ToString())).Text = d.Url;
            ((HiddenField)this.FindControl("hidBold" + (i + 1).ToString())).Value = d.FontWeight;
            ((HiddenField)this.FindControl("hidColor" + (i + 1).ToString())).Value = d.Color;
        }
    }
}